package com.movieknight;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.movieknight.MovieCheck;

public class FriendDeleteListAdapter extends ArrayAdapter<Friend> {
	private LayoutInflater li;
	
	public FriendDeleteListAdapter(Context context, List<Friend> friends) {
		super(context, 0, friends);
		li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final Friend friend = getItem(position);
		
		View v = convertView;
		if(v == null) {
			v = li.inflate(R.layout.friend, null);
		}
		
		/*final TextView idView = (TextView) v.findViewById(R.id.friendId);
		if(idView != null) {
			idView.setText("#" + friend.getId());
		}*/
		
		final TextView nameView = (TextView) v.findViewById(R.id.friendName);
		if(nameView != null) {
			nameView.setText(friend.getName());
		}
		
		return v;
	}
	
	public long getFriendId(int position) {
		return getItem(position).getId();
	}
	
	public String getFriendName(int position) {
		return getItem(position).getName();
	}
	
	public boolean hasStableIds() {
		return true;
	}
}